package com.bbzn.device.client.vo.res;

import com.bbzn.device.client.dataobject.FireImage;
import com.bbzn.device.client.dto.device.DeviceCountDTO;
import com.bbzn.device.client.dto.device.FireIndexDTO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;

/**
 * 设备统计DTO
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
public class FireIndexVO implements Serializable {

    private static final long serialVersionUID = 527864843958696847L;
    /**
     * 正常电压设备数
     */
    private Long nomalVoltageCount;

    /**
     * 故障电压设备数
     */
    private Long errorVoltageCount;

    /**
     * 工作中电压设备数
     */
    private Long workingVoltageCount;

    /**
     * 正常电流设备数
     */
    private Long nomalElectricCount;

    /**
     * 故障电流设备数
     */
    private Long errorElectricCount;

    /**
     * 工作中电流设备数
     */
    private Long workingElectricCount;

    /**
     * 正常发电设备数
     */
    private Long nomalGeneratorCount;

    /**
     * 故障发电设备数
     */
    private Long errorGeneratorCount;

    /**
     * 工作中发电设备数
     */
    private Long workingGeneratorCount;

    /**
     * 正常市电设备数
     */
    private Long nomalMunicipalElectricCount;

    /**
     * 故障市电设备数
     */
    private Long errorMunicipalElectricCount;

    /**
     * 工作中市电设备数
     */
    private Long workingMunicipalElectricCount;

    /**
     * 正常喷淋水泵设备数
     */
    private Long nomalSprayingPumpCount;

    /**
     * 故障喷淋水泵设备数
     */
    private Long errorSprayingPumpCount;

    /**
     * 工作中喷淋水泵设备数
     */
    private Long workingSprayingPumpCount;

    /**
     * 正常消防栓泵设备数
     */
    private Long nomalFirePumpsCount;

    /**
     * 故障消防栓泵设备数
     */
    private Long errorFirePumpsCount;

    /**
     * 工作中消防栓泵设备数
     */
    private Long workingFirePumpsCount;

    /**
     * 正常高位水箱水位设备数
     */
    private Long nomalHeightTankCount;

    /**
     * 故障高位水箱水位设备数
     */
    private Long errorHeightTankCount;

    /**
     * 工作中高位水箱水位设备数
     */
    private Long workingHeightTankCount;

    /**
     * 正常水池水位设备数
     */
    private Long nomalPoolTankCount;

    /**
     * 故障水池水位设备数
     */
    private Long errorPoolTankCount;

    /**
     * 工作中水池水位设备数
     */
    private Long workingPoolTankCount;

    /**
     * 正常水压设备数
     */
    private Long nomalpipelinePressureCount;

    /**
     * 故障水压设备数
     */
    private Long errorPipelinePressureCount;

    /**
     * 工作中水压设备数
     */
    private Long workingPipelinePressureCount;

    /**
     * 在线设备数
     */
    private Long onlineCount;

    /**
     * 离线设备数
     */
    private Long downLineCount;

    /**
     * 设备总数
     */
    private Integer totalDeviceCount;

    private List<DeviceCountDTO> deviceCountDTOS;

    /**
     * 压力:帕
     */
    private List<FireImage> fireImages;

    public void setAllValues(List<FireIndexDTO> dtos){

        this.nomalVoltageCount = dtos.stream().parallel().filter(dto -> dto.getVoltageStatus().equals(0)).count();
        this.errorVoltageCount = dtos.stream().parallel().filter(dto -> dto.getVoltageStatus().equals(2)).count();
        this.workingVoltageCount = dtos.stream().parallel().filter(dto -> dto.getVoltageStatus().equals(1)).count();

        this.nomalElectricCount = dtos.stream().parallel().filter(dto -> dto.getElectric().equals(0)).count();
        this.errorElectricCount = dtos.stream().parallel().filter(dto -> dto.getElectric().equals(2)).count();
        this.workingElectricCount = dtos.stream().parallel().filter(dto -> dto.getElectric().equals(1)).count();

        this.nomalGeneratorCount = dtos.stream().parallel().filter(dto -> dto.getGenerators().equals(0)).count();
        this.errorGeneratorCount = dtos.stream().parallel().filter(dto -> dto.getGenerators().equals(2)).count();
        this.workingGeneratorCount = dtos.stream().parallel().filter(dto -> dto.getGenerators().equals(1)).count();

        this.nomalMunicipalElectricCount = dtos.stream().parallel().filter(dto -> dto.getMunicipalElectric().equals(0)).count();
        this.errorMunicipalElectricCount = dtos.stream().parallel().filter(dto -> dto.getMunicipalElectric().equals(2)).count();
        this.workingMunicipalElectricCount = dtos.stream().parallel().filter(dto -> dto.getMunicipalElectric().equals(1)).count();

        this.nomalSprayingPumpCount = dtos.stream().parallel().filter(dto -> dto.getSprayingPump().equals(0)).count();
        this.errorSprayingPumpCount = dtos.stream().parallel().filter(dto -> dto.getSprayingPump().equals(2)).count();
        this.workingSprayingPumpCount = dtos.stream().parallel().filter(dto -> dto.getSprayingPump().equals(1)).count();

        this.nomalFirePumpsCount = dtos.stream().parallel().filter(dto -> dto.getFirePumps().equals(0)).count();
        this.errorFirePumpsCount = dtos.stream().parallel().filter(dto -> dto.getFirePumps().equals(2)).count();
        this.workingFirePumpsCount = dtos.stream().parallel().filter(dto -> dto.getFirePumps().equals(1)).count();

        this.nomalHeightTankCount = dtos.stream().parallel().filter(dto -> dto.getHeightTank().equals(0)).count();
        this.errorHeightTankCount = dtos.stream().parallel().filter(dto -> dto.getHeightTank().equals(2)).count();
        this.workingHeightTankCount = dtos.stream().parallel().filter(dto -> dto.getHeightTank().equals(1)).count();

        this.nomalPoolTankCount = dtos.stream().parallel().filter(dto -> dto.getPoolTank().equals(0)).count();
        this.errorPoolTankCount = dtos.stream().parallel().filter(dto -> dto.getPoolTank().equals(2)).count();
        this.workingPoolTankCount = dtos.stream().parallel().filter(dto -> dto.getPoolTank().equals(1)).count();

        this.nomalpipelinePressureCount = dtos.stream().parallel().filter(dto -> dto.getPipelinePressure().equals(0)).count();
        this.errorPipelinePressureCount = dtos.stream().parallel().filter(dto -> dto.getPipelinePressure().equals(2)).count();
        this.workingPipelinePressureCount = dtos.stream().parallel().filter(dto -> dto.getPipelinePressure().equals(1)).count();

        this.onlineCount = dtos.stream().parallel().filter(dto -> dto.getState().equals(1)).count();
        this.downLineCount = dtos.stream().parallel().filter(dto -> dto.getState().equals(0)).count();
        this.totalDeviceCount = dtos.size();
    }

    public FireIndexVO(List<FireIndexDTO> dtos) {
        setAllValues(dtos);
    }
}
